var $ = layui.$;
var wfId = parent.$("#viewTimeline").attr("wfId") || "";
var baseTaskId = parent.$("#viewTimeline").attr("baseTaskId") || "";
var vueData = new Vue({
    el: '#progressView_timeline',
    data: {
        sysTasks: []
    }
});

$(document).ready(function () {
    loadData();

    timelineAutoFit();

    $(window).resize(function() {
        timelineAutoFit();
    });
})

function loadData() {
    var url = '/wf/systask/listTimeLine';
    ActHttpRequest(url, {"sysTaskKeyId": baseTaskId}, function (data) {
        if (data.OK != "OK") {
            layer.alert(data.OK);
            return;
        }
        if (data.List.length > 0) {
            $.each(data.List, function (index, idata) {
                data.List[index].taskType = taskType(idata.participateType, idata.operationType)
            });
            Vue.set(vueData, "sysTasks", data.List);
        }
    })
}

function taskType(participateType, operationType) {
    ret = ""
    switch (participateType) {
        case "1":
            ret = "单人 "
            break
        case "2":
            ret = "多人 "
            break
    }

    switch (operationType) {
        case "1":
            ret += "串行"
            break
        case "2":
            ret += "并行"
            break
        case "3":
            ret += "抢占"
            break
        case "4":
            ret += "协作"
            break
    }

    return ret
}

function timelineAutoFit() {
    var div = document.getElementById("progressView_timeline");
    div.style.height = (window.innerHeight - 40) + 'px';
}